to
can be <phone Number>@c.us
, <phone Number>-<groupId>@g.us
, or <phone Number><groupId>@g.us
.To use these functions, it is necessary to initialize the bot.
Click here to learn more.
you can send messages only using one function!
// send text message
await client.sendMessage({
to: "0000000000@c.us", // you can pass the contact number or group number
body: "A message sent by hydra-bot", // message text
options: {
type: 'sendText', // shipping type
}
}).then((result) => {
console.log(result); // message result
}).catch((error) => {
console.log(error); // message error
});
// send text message
await client.sendMessage({
to: "0000000000@c.us", // you can pass the contact number or group number
body: './file.pdf', // you can use a directory or use a url
options: {
type: 'sendFile', // shipping type
filename: 'filename' // put the file name here
}
}).then((result) => {
console.log(result); // message result
}).catch((error) => {
console.log(error); // message error
});
// send file audio
await client.sendMessage({
to: "0000000000@c.us", // you can pass the contact number or group number
body: './file.mp3', // you can use a directory or use a url
options: {
type: 'sendAudio', // shipping type
}
}).then((result) => {
console.log(result); // message result
}).catch((error) => {
console.log(error); // message error
});
// Send audio file base64
await client.sendMessage({
to: "0000000000@c.us", // you can pass the contact number or group number
body: base64MP3, // you can use a directory or use a url
options: {
type: 'sendAudioBase64', // shipping type
}
}).then((result) => {
console.log(result); // message result
}).catch((error) => {
console.log(error); // message error
});
// Send image message
await client.sendMessage({
to: "0000000000@c.us", // you can pass the contact number or group number
body: './file.jpg', // you can use a directory or use a url
options: {
type: 'sendImage', // shipping type
caption: 'image text' // image text
}
}).then((result) => {
console.log(result); // message result
}).catch((error) => {
console.log(error); // message error
});
// Send image Base64
await client.sendMessage({
to: "0000000000@c.us", // you can pass the contact number or group number
body: base64IMG, // you can use a directory or use a url
options: {
type: 'sendImageFromBase64', // shipping type
caption: 'image text' // image text
}
}).then((result) => {
console.log(result); // message result
}).catch((error) => {
console.log(error); // message error
});
Generated using TypeDoc